app = {} //The app table is deleted later, so store data in app.app._ = {} instead. Not using the table app.app._ in specific will cause problems.
app.folder = {"Notes"} //This table should have one key and one value, key of one, value of a string. This is for FUTURE subfolder support.
app.app = {
	caption = "Number",
	options = {
			close = true,
			minimize = true,
		},
	x = ScrW()*.5 - 294*.5,
	y = ScrH()*.5 - 176*.5,
	w = 380+26,
	h = 72,
	_ = {
		cur = nil,
		expanded = true,
	},
	draw = function(self)
		if not self.visible then
			return
		end
		local s = hack.scheme
		self:DrawWindowPre()
		
		local disp = tostring(self._.cur or "")
		if #disp > 41 then
			disp = "Error"
		end
		
		if self._.expanded then
			self:DrawRoundedRect(12,12,self.w-24,12,4,Color(255,255,255,255),true)
			self:DrawText(disp,"Trebuchet24",self.w-12,6,Color(0,0,0,255),2)
			
			local button = {
				y = 38,
				w = 24,
				h = 24,
				font = "Trebuchet24",
			}
			
			local i = 0
			local numIn
			for x = 0,234,26 do
				button.x = x+8
				button.label = i
				local newIn = self:DrawForm(i,"button",button)
				if newIn == -1 then
					newIn = i
				else
					newIn = nil
				end
				numIn = numIn or newIn
				i = i+1
			end
			
			local opIn
			do
				button.label = "."
				button.x = 268
				local newIn = self:DrawForm(button.label,"button",button)
				if newIn == -1 then
					newIn = "."
				else
					newIn = nil
				end
				numIn = numIn or newIn
				
				button.label = "<"
				button.x = 294
				local newIn = self:DrawForm(button.label,"button",button)
				if newIn == -1 then
					newIn = "<"
				else
					newIn = nil
				end
				opIn = opIn or newIn
				
				button.label = "C"
				button.x = 294+26
				local newIn = self:DrawForm(button.label,"button",button)
				if newIn == -1 then
					newIn = "C"
				else
					newIn = nil
				end
				opIn = opIn or newIn
				
				button.label = "+-"
				button.x = 320+26
				local newIn = self:DrawForm(button.label,"button",button)
				if newIn == -1 then
					newIn = "+-"
				else
					newIn = nil
				end
				opIn = opIn or newIn
				
				button.label = "^"
				button.x = 320+26+26
				local newIn = self:DrawForm(button.label,"button",button)
				if newIn == -1 then
					newIn = "^"
				else
					newIn = nil
				end
				opIn = opIn or newIn
			end
			
			if numIn then
				self._.cur = (self._.cur or "")..numIn
			end
			
			if opIn and self._.cur then
				if opIn == "<" then
					if self._.cur and #self._.cur > 0 then
						self._.cur = string.sub(self._.cur,1,-2)
					end
				elseif opIn == "C" then
					self._.cur = nil
				elseif opIn == "+-" then
					if string.sub(self._.cur,1,1) == "-" then
						self._.cur = string.sub(self._.cur,2)
					else
						self._.cur = "-"..self._.cur
					end
				end
			end
			if opIn == "^" then
				Msg("^")
				self.h = 38
				surface.SetFont("Trebuchet24")
				self.w = math.max(103,surface.GetTextSize(disp)+48)
				self._.expanded = false
			end
		else
			self:DrawRoundedRect(12,12,self.w-24-26,12,4,Color(255,255,255,255),true)
			self:DrawText(self._.cur or "","Trebuchet24",self.w-12-26,6,Color(0,0,0,255),2)
			
			local button = {
				x = self.w-29,
				y = 6,
				w = 24,
				h = 24,
				font = "Trebuchet24",
				label = "v",
			}
			if self:DrawForm(button.label,"button",button) == -1 then
				self.w = 380+26
				self.h = 72
				self._.expanded = true
			end
		end
		
		self:DrawWindowPost()
	end,
}
























































